#ifndef __tenacitas_log__level__h__
#define __tenacitas_log__level__h__


// =============================================================================
/** @file */

// =============================================================================
/** todo */

// =============================================================================
//                                 C++ Headers
#include <cstdint>
#include <string>

// =============================================================================
//                                 3rds Headers

#include <boost/thread/thread.hpp>
// =============================================================================
//                                 Our Headers


// =============================================================================
//                                 Namespaces
using namespace std;


// =============================================================================
//                                 Macro Contants
/** */


// =============================================================================
//                                 Macro Commands
/** */


/** namespace of the organization */
namespace tenacitas {
    /** namespace for the project */
    namespace log {

        // =========================== Typedefs ===========================
        
        // ============================ Pre-Declarations ==================

        // ============================ Attributes ========================
        /** */
        

        // ============================ Functions =========================
        /** */
        int64_t th2int( boost::thread::id p_id );
        
        // ============================ Classes ===========================
        /** 
            @nosubgrouping 
        */
        class level {

            // --- level - Friends --------------------------------------

        public:

            // --- level - Public Internal Types ------------------------

            /** */
            typedef int16_t value;


            // --- level - Public Constructors --------------------------

            /** */
            level( const level & p_level )
            : m_value( p_level.m_value ) {}
            

            /** Destructor */
            ~level( ) {}
            

            // --- level - Public Accessors -----------------------------

            /** */
            std::string str( ) const {
                if ( m_value == trace.val( ) ) { return "trace"; }
                if ( m_value == debug.val( ) ) { return "debug"; }
                if ( m_value == info.val( ) ) { return "info"; }
                if ( m_value == warn.val( ) ) { return "warn"; }
                if ( m_value == error.val( ) ) { return "error"; }
                if ( m_value == critical.val( ) ) { return "critical"; }

                throw std::string( "It should be impossible, but an "
                                   "invalid 'tenacitas::log::level' "
                                   "was created" );
            }

            // --- level - Public Processors ----------------------------

            /** */
            static const level & create( const std::string & p_str ) {
                if ( p_str == "trace" ) { return trace; }
                if ( p_str == "debug" ) { return debug; }
                if ( p_str == "info" ) { return info; }
                if ( p_str == "warn" ) { return warn; }
                if ( p_str == "error" ) { return error; }
                if ( p_str == "critical" ) { return critical; }

                throw std::string ( "Invalid string for a 'tenacitas::log::level' value ");
            }

            // --- level - Public Operators -----------------------------

            /** */
            value val( ) const {
                return m_value;
            }
            

            /** */
            level & operator = ( const level & p_level ) {
                if ( this != & p_level ) {
                    m_value = p_level.m_value;
                }
                return *this;
            }

            /** */
            bool operator == ( const level & p_level ) const {
                return m_value == p_level.m_value;
            }

            /** */
            bool operator != ( const level & p_level ) const {
                return m_value != p_level.m_value;
            }

            bool operator >= ( const level & p_level ) const {
                return m_value >= p_level.m_value;
            }

            bool operator > ( const level & ) const = delete;

            bool operator <= ( const level & p_level ) const {
                return m_value <= p_level.m_value;
            }

	    bool operator < ( const level & ) const = delete;

            // --- level - Public Attributes ----------------------------

            static const level trace;
            static const level debug;
            static const level info;
            static const level warn;
            static const level error;
            static const level critical;

        private:
            // --- level - Private Constructors -------------------------

            /** */
            level( value p_value )
            : m_value( p_value ) {
            }

            // --- level - Private Attributes ---------------------------

            /** */
            value m_value;
        };
    }
}

// =============================================================================
//                     I M P L E M E N T A T I O N
// =============================================================================

using namespace tenacitas::log;



#endif
